Wordle Solver
- Automation
- Python
- Pandas
- PyAutoGUI
One weekend when I was in between finishing most of my MTGMetaTracker project and starting my work with Vue.js, I want a quick casual project that would be engaging as I went through transition period. I had the idea since my girlfriend and I had been playing Wordle a lot at the time, what if I make a Python program that can solve Wordle. To me this felt perfect, I would get to work with some automation technology, get a refresher on a very relevant language I have not used in awhile, and it would be lightweight yet challenging.
First step was to get Wordle's word data, which was simple. I found it online along with each words probability of being the word of the day. I read this csv file using Pandas and from here we set up the PyAutoGUI. This was fairly straight forward as well, just needed to figure how my program could recognize the board and the colors of the guesses. Using an image of empty my program can detect where the board is on the screen, then after each guess the program would identify what colors a guess returned by checking each square.
The last step to this application was the logic behind guessing. This was the most involved step of the program, and currently I am even testing and optimizing it. The best way I found to keep track of letters was to create three global variables: a dictionary for Yellow Letters where each key is a letter and the value is the array of the positions it was found to be yellow, a five index array for Green Letters, and an array for Gray Letters. Each of these containers were custom for the letters color to make it easier on our logic. My logic for generate the best guess was to check Grays, Yellows, then Greens, and the loop would check positions 1-5 since positioning is very important for Yellows and Greens. As the program goes through these checks it whittles down my list of possible words, and then after these checks the best is index 0, because the list is sorted by its "Occurrence" aka probability to be the right answer.
As of right now for this project its about working out any kinks with testing, and making this program faster. It feels clunky, a rewrite in Go or Rust could be in the future.